﻿#include "DialogHeatGraph2DSettings.h"
#include "ui_DialogHeatGraph2DSettings.h"

#include <QPushButton>
#include <QLineEdit>
#include <QComboBox>
#include <QCheckBox>
#include <QTableWidgetItem>
#include <QHeaderView>
#include <QTabBar>
#include <QtGlobal>

#include "IdaWidgetHelper.h"
#include "IdaDialogMsg.h"
#include "DataHeatGraph2DSettings.h"

#include "BaseModule/GlobalHelper.h"
#include "StyleComboBox.h"
#include "BaseWidget/DoubleSpinBox.h"
#include "BaseWidget/EColorComboBox.h"
#include "BaseModule/IBaseSignal.h"
#include "BaseWidget/IdaDialogMsg.h"

namespace pst
{
    DialogHeatGraph2DSettings::DialogHeatGraph2DSettings(QWidget* parent)
        : IdaDialogFrame(parent), ui(new Ui::DialogHeatGraph2DSettings()), m_tableWidget_colorBar(nullptr), m_tableWidget_xAxisDisplay(nullptr), m_tableWidget_xAxisRange(nullptr), m_tableWidget_yAxisDisplay(nullptr), m_tableWidget_yAxisRange(nullptr), m_tableWidget_grid(nullptr), m_tableWidget_title(nullptr), m_dataHeatGraph2DSettings(nullptr)
    {
        ui->setupUi(this);

        initWidget();
    }

    DialogHeatGraph2DSettings::~DialogHeatGraph2DSettings()
    {
        delete ui;
        //if (m_dataHeatGraph2DSettings)
        //{
        //    delete m_dataHeatGraph2DSettings;
        //    m_dataHeatGraph2DSettings = nullptr;
        //}
    }

    void DialogHeatGraph2DSettings::setWindowUniversalID(int windowUniversalID)
    {
        m_windowUniversalID = windowUniversalID;
    }

    void DialogHeatGraph2DSettings::initWidget()
    {
        setWindowSize(740, 400);
        setWindowTitle(QStringLiteral("显示设置"));

        // auto _button_apply = new QPushButton(QStringLiteral("应用"));
        // ui->buttonBox->addButton(_button_apply, QDialogButtonBox::YesRole);
        connect(ui->pushButton_reject, &QPushButton::clicked, this, &DialogHeatGraph2DSettings::reject);
        connect(ui->pushButton_accept, &QPushButton::clicked, this, &DialogHeatGraph2DSettings::accept);
        connect(ui->pushButton_apply, &QPushButton::clicked, this, &DialogHeatGraph2DSettings::slot_apply);

        IdaWidgetHelperInstance->setMainButtonStyle(ui->pushButton_accept); // 将确定设置为主按钮

        m_tableWidget_colorBar = initData_colorBar();
        m_tableWidget_xAxisDisplay = initData_xAxisDisplay();
        m_tableWidget_xAxisRange = initData_xAxisRange();
        m_tableWidget_yAxisDisplay = initData_yAxisDisplay();
        m_tableWidget_yAxisRange = initData_yAxisRange();
        m_tableWidget_grid = initData_grid();
        m_tableWidget_title = initData_title();

        IdaWidgetHelperInstance->setTableWidgetStyle(m_tableWidget_colorBar);
        IdaWidgetHelperInstance->setTableWidgetStyle(m_tableWidget_xAxisDisplay);
        IdaWidgetHelperInstance->setTableWidgetStyle(m_tableWidget_xAxisRange);
        IdaWidgetHelperInstance->setTableWidgetStyle(m_tableWidget_yAxisDisplay);
        IdaWidgetHelperInstance->setTableWidgetStyle(m_tableWidget_yAxisRange);
        IdaWidgetHelperInstance->setTableWidgetStyle(m_tableWidget_grid);
        IdaWidgetHelperInstance->setTableWidgetStyle(m_tableWidget_title);

        ui->gridLayout_colorBar->addWidget(m_tableWidget_colorBar);
        ui->gridLayout_xAxisDisplay->addWidget(m_tableWidget_xAxisDisplay);
        ui->gridLayout_xAxisRange->addWidget(m_tableWidget_xAxisRange);
        ui->gridLayout_yAxisDisplay->addWidget(m_tableWidget_yAxisDisplay);
        ui->gridLayout_yAxisRange->addWidget(m_tableWidget_yAxisRange);
        ui->gridLayout_grid->addWidget(m_tableWidget_grid);
        ui->gridLayout_title->addWidget(m_tableWidget_title);
        
        //ui->tab_6->hide();//隐藏网格设置
        int index = ui->tabWidget->indexOf(ui->tab_6);
        ui->tabWidget->removeTab(index);


        //m_dataHeatGraph2DSettings = new DataHeatGraph2DSettings();

        // 将数据实例指针 传递给 临时数据类进行数据复制
        // m_dataHeatGraph2DSettings->copyData(数据实例指针);
        return;
        updateUIData_colorBar();
        updateUIData_xAxisDisplay();
        updateUIData_xAxisRange();
        updateUIData_yAxisDisplay();
        updateUIData_yAxisRange();
        updateUIData_grid();
        updateUIData_title();
    }

    void DialogHeatGraph2DSettings::initData(DataHeatGraph2DSettings* dataHeatGraph2DSettings)
    {
        if (dataHeatGraph2DSettings != nullptr)
        {
            //m_dataHeatGraph2DSettings->copyData(dataHeatGraph2DSettings);
            m_dataHeatGraph2DSettings = dataHeatGraph2DSettings;
            updateUIData_colorBar();
            updateUIData_xAxisDisplay();
            updateUIData_xAxisRange();
            updateUIData_yAxisDisplay();
            updateUIData_yAxisRange();
            updateUIData_grid();
            updateUIData_title();
        }
    }

    void DialogHeatGraph2DSettings::ChangeCurrentWidget(int index)
    {
        ui->tabWidget->setCurrentIndex(index);
    }

    void DialogHeatGraph2DSettings::reject()
    {

        IdaDialogFrame::reject();
    }

    void DialogHeatGraph2DSettings::accept()
    {
        if (slot_apply())
        {
            IdaDialogFrame::accept();
        }
    }

    bool DialogHeatGraph2DSettings::slot_apply()
    {
        auto _tableWidget = m_tableWidget_colorBar;
        int _rowCount = -1;
        auto _checkBox_isAutoRange = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                   // 自动范围
        if (!_checkBox_isAutoRange->isChecked())
        {
            auto _doubleSpinBox_maxValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 最大值
            auto _doubleSpinBox_minValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 最小值
            auto _maxvalue = _doubleSpinBox_maxValue->value();
            auto _minvalue = _doubleSpinBox_minValue->value();
            if (_maxvalue == _minvalue)
            {
                IdaDialogMsg::showDialog(this, QString("最大值与最小值不得相等，请重新输入"), EDialogMsg::Error, tr("颜色条最值错误"));
                return false;
            }
            if (_maxvalue < _minvalue)
            {
                _doubleSpinBox_maxValue->setValue(_minvalue);
                _doubleSpinBox_minValue->setValue(_maxvalue);
            }
        }
        saveUIData_colorBar();
        saveUIData_xAxisDisplay();
        saveUIData_xAxisRange();
        saveUIData_yAxisDisplay();
        saveUIData_yAxisRange();
        saveUIData_grid();
        saveUIData_title();

        auto _colorBar = m_dataHeatGraph2DSettings->getColorBar();
        auto _xAxisDisplay = m_dataHeatGraph2DSettings->getXAxisDisplay();
        auto _xAxisRange = m_dataHeatGraph2DSettings->getXAxisRange();
        auto _yAxisDisplay = m_dataHeatGraph2DSettings->getYAxisDisplay();
        auto _yAxisRange = m_dataHeatGraph2DSettings->getYAxisRange();
        auto _grid = m_dataHeatGraph2DSettings->getGrid();
        auto _title = m_dataHeatGraph2DSettings->getTitle();

        auto scalarBarIsAutoRange = _colorBar->m_isAutoRange;
        auto scalarBarMax = _colorBar->m_maxValue;
        auto scalarBarMin = _colorBar->m_minValue;
        auto scalarBarColor = _colorBar->m_fontColor;
        auto scalarBarFontSize = _colorBar->m_fontSize;

        auto XAxisAutoTitle = _xAxisDisplay->m_isAutoName;
        auto XAxisTitle = _xAxisDisplay->m_titleText;
        auto XTitleFontColor = _xAxisDisplay->m_titleFontColor;
        auto XTitleFontSize = _xAxisDisplay->m_titleFontSize;
        auto XAxisColor = _xAxisDisplay->m_axisColor;
        auto XAisThickness = _xAxisDisplay->m_axisThickness;
        auto XValuePrecision = _xAxisDisplay->m_valuePrecision;
        auto XAxisDigitColor = _xAxisDisplay->m_axisDigitColor;
        auto XAxisDigitSize = _xAxisDisplay->m_axisDigitSize;

        auto XAxisIsAutoRange = _xAxisRange->m_isAutoRange;
        auto XAxisMax = _xAxisRange->m_maxValue;
        auto XAxisMin = _xAxisRange->m_minValue;
        auto XIsAutoStepSize = _xAxisRange->m_isAutoStepSize;
        auto XCustomStepSize = _xAxisRange->m_customStepSize;

        auto YAxisAutoTitle = _yAxisDisplay->m_isAutoName;
        auto YAxisTitle = _yAxisDisplay->m_titleText;
        auto YTitleFontColor = _yAxisDisplay->m_titleFontColor;
        auto YTitleFontSize = _yAxisDisplay->m_titleFontSize;
        auto YAxisColor = _yAxisDisplay->m_axisColor;
        auto YAisThickness = _yAxisDisplay->m_axisThickness;
        auto YValuePrecision = _yAxisDisplay->m_valuePrecision;
        auto YAxisDigitColor = _yAxisDisplay->m_axisDigitColor;
        auto YAxisDigitSize = _yAxisDisplay->m_axisDigitSize;

        auto YAxisIsAutoRange = _yAxisRange->m_isAutoRange;
        auto YAxisMax = _yAxisRange->m_maxValue;
        auto YAxisMin = _yAxisRange->m_minValue;
        auto YIsAutoStepSize = _yAxisRange->m_isAutoStepSize;
        auto YCustomStepSize = _yAxisRange->m_customStepSize;

        auto gridIsMainGridLineDisplay = _grid->m_isMainGridLineDisplay;
        auto gridMainGridLineColor = _grid->m_mainGridLineColor;
        auto gridMainGridLineStyle = _grid->m_mainGridLineStyle;
        auto gridMainGridLineThickness = _grid->m_mainGridLineThickness;
        auto gridIsSecondaryGridLineDisplay = _grid->m_isSecondaryGridLineDisplay;
        auto gridSecondaryGridLineColor = _grid->m_secondaryGridLineColor;
        auto gridSecondaryGridLineStyle = _grid->m_secondaryGridLineStyle;
        auto gridSecondaryGridLineThickness = _grid->m_secondaryGridLineThickness;

        auto windowTitleName = _title->m_titleName;
        auto windowTitleFontColor = _title->m_titleFontColor;
        auto windowTitleFontSize = _title->m_titleFontSize;

        QList<int> scalarBarColorList = {scalarBarColor.red(), scalarBarColor.green(), scalarBarColor.blue()};
        QString _scalarBarColor = GlobalHelperInstance->convertIntListToQString(scalarBarColorList);
        QList<int> XTitleFontColorList = {XTitleFontColor.red(), XTitleFontColor.green(), XTitleFontColor.blue()};
        QString _XTitleFontColor = GlobalHelperInstance->convertIntListToQString(XTitleFontColorList);
        QList<int> XAxisColorList = {XAxisColor.red(), XAxisColor.green(), XAxisColor.blue()};
        QString _XAxisColor = GlobalHelperInstance->convertIntListToQString(XAxisColorList);
        QList<int> XAxisDigitColorList = {XAxisDigitColor.red(), XAxisDigitColor.green(), XAxisDigitColor.blue()};
        QString _XAxisDigitColor = GlobalHelperInstance->convertIntListToQString(XAxisDigitColorList);
        QList<int> YTitleFontColorList = {YTitleFontColor.red(), YTitleFontColor.green(), YTitleFontColor.blue()};
        QString _YTitleFontColor = GlobalHelperInstance->convertIntListToQString(YTitleFontColorList);
        QList<int> YAxisColorList = {YAxisColor.red(), YAxisColor.green(), YAxisColor.blue()};
        QString _YAxisColor = GlobalHelperInstance->convertIntListToQString(YAxisColorList);
        QList<int> YAxisDigitColorList = {YAxisDigitColor.red(), YAxisDigitColor.green(), YAxisDigitColor.blue()};
        QString _YAxisDigitColor = GlobalHelperInstance->convertIntListToQString(YAxisDigitColorList);
        QList<int> gridMainGridLineColorList = {gridMainGridLineColor.red(), gridMainGridLineColor.green(), gridMainGridLineColor.blue()};
        QString _gridMainGridLineColor = GlobalHelperInstance->convertIntListToQString(gridMainGridLineColorList);
        QList<int> gridSecondaryGridLineColorList = {gridSecondaryGridLineColor.red(), gridSecondaryGridLineColor.green(), gridSecondaryGridLineColor.blue()};
        QString _gridSecondaryGridLineColor = GlobalHelperInstance->convertIntListToQString(gridSecondaryGridLineColorList);
        QList<int> windowTitleFontColorList = {windowTitleFontColor.red(), windowTitleFontColor.green(), windowTitleFontColor.blue()};
        QString _windowTitleFontColor = GlobalHelperInstance->convertIntListToQString(windowTitleFontColorList);

        QStringList _pyCodes{};
        _pyCodes += QString("heatmapmainsetting = PostProcessing.HeatMapMainSetting()");
        _pyCodes += QString("heatmapmainsetting.setWindowId(%1)").arg((int)m_windowUniversalID);
        _pyCodes += QString("heatmapmainsetting.setScalarBarData(%1,%2,%3,\"%4\",%5)").arg((bool)scalarBarIsAutoRange).arg((double)scalarBarMax).arg((double)scalarBarMin).arg(_scalarBarColor).arg((int)scalarBarFontSize);

        _pyCodes += QString("heatmapmainsetting.setXAxisData(%1,\"%2\",\"%3\",%4,\"%5\",%6,%7,\"%8\",%9,%10,%11,%12,%13,%14)").arg(XAxisAutoTitle).arg(XAxisTitle).arg(_XTitleFontColor).arg((int)XTitleFontSize).arg(_XAxisColor).arg((double)XAisThickness).arg((int)XValuePrecision).arg(_XAxisDigitColor).arg((int)XAxisDigitSize).arg((bool)XAxisIsAutoRange).arg((double)XAxisMax).arg((double)XAxisMin).arg((bool)XIsAutoStepSize).arg((double)XCustomStepSize);

        _pyCodes += QString("heatmapmainsetting.setYAxisData(%1,\"%2\",\"%3\",%4,\"%5\",%6,%7,\"%8\",%9,%10,%11,%12,%13,%14)").arg(YAxisAutoTitle).arg(YAxisTitle).arg(_YTitleFontColor).arg((int)YTitleFontSize).arg(_YAxisColor).arg((double)YAisThickness).arg((int)YValuePrecision).arg(_YAxisDigitColor).arg((int)YAxisDigitSize).arg((bool)YAxisIsAutoRange).arg((double)YAxisMax).arg((double)YAxisMin).arg((bool)YIsAutoStepSize).arg((double)YCustomStepSize);

        _pyCodes += QString("heatmapmainsetting.setGridData(%1,\"%2\",%3,%4,%5,\"%6\",%7,%8)").arg((int)gridIsMainGridLineDisplay).arg(_gridMainGridLineColor).arg((int)gridMainGridLineStyle).arg((double)gridMainGridLineThickness).arg((int)gridIsSecondaryGridLineDisplay).arg(_gridSecondaryGridLineColor).arg((int)gridSecondaryGridLineStyle).arg((double)gridSecondaryGridLineThickness);

        _pyCodes += QString("heatmapmainsetting.setWindowTitle(\"%1\",\"%2\",%3)").arg(windowTitleName).arg(_windowTitleFontColor).arg((int)windowTitleFontSize);
        _pyCodes += QString("heatmapmainsetting.saveHeatMapMainSettingData()");
        emit IBaseSignalInstance->signal_execPYCode(_pyCodes, true, false);

        //emit IBaseSignalInstance->signal_saveHeatMapMainSettingData((int)m_mainWindowId,
        //                                                            scalarBarIsAutoRange,
        //                                                            scalarBarMin,
        //                                                            scalarBarMax,
        //                                                            _scalarBarColor,
        //                                                            scalarBarFontSize,
        //                                                            XAxisAutoTitle,
        //                                                            XAxisTitle,
        //                                                            _XTitleFontColor,
        //                                                            XTitleFontSize,
        //                                                            _XAxisColor,
        //                                                            XAisThickness,
        //                                                            XValuePrecision,
        //                                                            _XAxisDigitColor,
        //                                                            XAxisDigitSize,
        //                                                            XAxisIsAutoRange,
        //                                                            XAxisMax,
        //                                                            XAxisMin,
        //                                                            XIsAutoStepSize,
        //                                                            XCustomStepSize,
        //                                                            YAxisAutoTitle,
        //                                                            YAxisTitle,
        //                                                            _YTitleFontColor,
        //                                                            YTitleFontSize,
        //                                                            _YAxisColor,
        //                                                            YAisThickness,
        //                                                            YValuePrecision,
        //                                                            _YAxisDigitColor,
        //                                                            YAxisDigitSize,
        //                                                            YAxisIsAutoRange,
        //                                                            YAxisMax,
        //                                                            YAxisMin,
        //                                                            YIsAutoStepSize,
        //                                                            YCustomStepSize,
        //                                                            gridIsMainGridLineDisplay,
        //                                                            _gridMainGridLineColor,
        //                                                            gridMainGridLineStyle,
        //                                                            gridMainGridLineThickness,
        //                                                            gridIsSecondaryGridLineDisplay,
        //                                                            _gridSecondaryGridLineColor,
        //                                                            gridSecondaryGridLineStyle,
        //                                                            gridSecondaryGridLineThickness,
        //                                                            windowTitleName,
        //                                                            _windowTitleFontColor,
        //                                                            windowTitleFontSize);

        // 将临时数据类 传递给 数据实例指针进行数据复制
        // 数据实例指针->copyData(m_dataHeatGraph2DSettings);
        emit signal_sendData(m_windowUniversalID, m_curveInfoID);
        return true;
    }

    QTableWidget* DialogHeatGraph2DSettings::initData_colorBar()
    {
        auto _tableWidget = new QTableWidget();
        _tableWidget->setColumnCount(2);
        _tableWidget->setRowCount(5);
        _tableWidget->setHorizontalHeaderLabels(QStringLiteral("名称,值").split(","));
        _tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

        auto _fontSizeList = GlobalHelperInstance->getFontSizeList();

        int _rowCount = -1;
        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("自动范围")));
        auto _checkBox_isAutoRange = new QCheckBox(); // 自动范围
        _tableWidget->setCellWidget(_rowCount, 1, _checkBox_isAutoRange);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("最大值")));
        auto _doubleSpinBox_maxValue = new BaseWidget::DoubleSpinBox(); // 最大值
        _doubleSpinBox_maxValue->setRange(-1e15, 1e15);
        _doubleSpinBox_maxValue->setDecimals(15);
        _tableWidget->setCellWidget(_rowCount, 1, _doubleSpinBox_maxValue);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("最小值")));
        auto _doubleSpinBox_minValue = new BaseWidget::DoubleSpinBox(); // 最小值
        _doubleSpinBox_minValue->setRange(-1e15, 1e15);
        _doubleSpinBox_minValue->setDecimals(15);
        _tableWidget->setCellWidget(_rowCount, 1, _doubleSpinBox_minValue);

        /*
         * checkbox 控制禁用状态
         */
        connect(_checkBox_isAutoRange, &QCheckBox::toggled, this,
                [=](bool checked)
                {
                    _doubleSpinBox_maxValue->setEnabled(!checked);
                    _doubleSpinBox_minValue->setEnabled(!checked);
                });

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("字体颜色")));
        auto _comboBox_fontColor = new BaseWidget::EColorComboBox; // 字体颜色
        _comboBox_fontColor->appendPredefinedColors();
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_fontColor);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("字体大小")));
        auto _comboBox_fontSize = new QComboBox; // 字体大小
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_fontSize);
        for (int i = 0; i < _fontSizeList.size(); ++i)
        {
            _comboBox_fontSize->addItem(_fontSizeList.at(i));
        }

        // 设置第一列不可编辑
        for (int _row = 0; _row < _tableWidget->rowCount(); ++_row)
        {
            QTableWidgetItem* item = _tableWidget->item(_row, 0);
            item->setFlags(item->flags() & ~Qt::ItemIsEditable);
        }

        return _tableWidget;
    }

    QTableWidget* DialogHeatGraph2DSettings::initData_xAxisDisplay()
    {
        auto _tableWidget = new QTableWidget;
        _tableWidget->setColumnCount(2);
        _tableWidget->setRowCount(9);
        _tableWidget->setHorizontalHeaderLabels(QStringLiteral("名称,值").split(","));
        _tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

        auto _fontSizeList = GlobalHelperInstance->getFontSizeList();
        auto _lineWidthList = GlobalHelperInstance->getLineWidthList();

        int _rowCount = -1;
        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("自动命名")));
        auto _checkBox_isAutoName = new QCheckBox(); // 自动命名
        _tableWidget->setCellWidget(_rowCount, 1, _checkBox_isAutoName);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("标题名")));
        auto _lineEdit_title = new QLineEdit; // 标题名
        _tableWidget->setCellWidget(_rowCount, 1, _lineEdit_title);


        /*
         * checkbox 控制禁用状态
         */
        connect(_checkBox_isAutoName, &QCheckBox::toggled, this,
                [=](bool checked)
                {
                    _lineEdit_title->setEnabled(!checked);
                });


        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("标题字体颜色")));
        auto _comboBox_titleFontColor = new BaseWidget::EColorComboBox; // 标题字体颜色
        _comboBox_titleFontColor->appendPredefinedColors();
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_titleFontColor);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("标题字体大小")));
        auto _comboBox_titleFontSize = new QComboBox; // 标题字体大小
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_titleFontSize);
        for (int i = 0; i < _fontSizeList.size(); ++i)
        {
            _comboBox_titleFontSize->addItem(_fontSizeList.at(i));
        }

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("轴线颜色")));
        auto _comboBox_axisColor = new BaseWidget::EColorComboBox; // 轴线颜色
        _comboBox_axisColor->appendPredefinedColors();
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_axisColor);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("轴线粗细")));
        auto _comboBox_axisThickness = new QComboBox; // 轴线粗细
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_axisThickness);
        for (int i = 0; i < _lineWidthList.size(); ++i)
        {
            _comboBox_axisThickness->addItem(_lineWidthList.at(i));
        }

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("数值精度")));
        auto _SpinBox_valuePrecision = new QSpinBox; // 数值精度
        _SpinBox_valuePrecision->setRange(0, 15);
        _tableWidget->setCellWidget(_rowCount, 1, _SpinBox_valuePrecision);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("轴数字颜色")));
        auto _comboBox_axisDigitColor = new BaseWidget::EColorComboBox; // 轴数字颜色
        _comboBox_axisDigitColor->appendPredefinedColors();
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_axisDigitColor);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("轴数字大小")));
        auto _comboBox_axisDigitSize = new QComboBox; // 轴数字大小
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_axisDigitSize);
        for (int i = 0; i < _fontSizeList.size(); ++i)
        {
            _comboBox_axisDigitSize->addItem(_fontSizeList.at(i));
        }

        // 设置第一列不可编辑
        for (int _row = 0; _row < _tableWidget->rowCount(); ++_row)
        {
            QTableWidgetItem* item = _tableWidget->item(_row, 0);
            item->setFlags(item->flags() & ~Qt::ItemIsEditable);
        }

        return _tableWidget;
    }

    QTableWidget* DialogHeatGraph2DSettings::initData_xAxisRange()
    {
        auto _tableWidget = new QTableWidget;
        _tableWidget->setColumnCount(2);
        _tableWidget->setRowCount(5);
        _tableWidget->setHorizontalHeaderLabels(QStringLiteral("名称,值").split(","));
        _tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

        int _rowCount = -1;
        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("自动范围")));
        auto _checkBox_isAutoRange = new QCheckBox(); // 自动范围
        _tableWidget->setCellWidget(_rowCount, 1, _checkBox_isAutoRange);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("最大值")));
        auto _doubleSpinBox_maxValue = new BaseWidget::DoubleSpinBox(); // 最大值
        _doubleSpinBox_maxValue->setRange(-1e15, 1e15);
        _doubleSpinBox_maxValue->setDecimals(15);
        _tableWidget->setCellWidget(_rowCount, 1, _doubleSpinBox_maxValue);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("最小值")));
        auto _doubleSpinBox_minValue = new BaseWidget::DoubleSpinBox(); // 最小值
        _doubleSpinBox_minValue->setRange(-1e15, 1e15);
        _doubleSpinBox_minValue->setDecimals(15);
        _tableWidget->setCellWidget(_rowCount, 1, _doubleSpinBox_minValue);

        /*
         * checkbox 控制禁用状态
         */
        connect(_checkBox_isAutoRange, &QCheckBox::toggled, this,
                [=](bool checked)
                {
                    _doubleSpinBox_maxValue->setEnabled(!checked);
                    _doubleSpinBox_minValue->setEnabled(!checked);
                });

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("自动步长")));
        auto _checkBox_isAutoStepSize = new QCheckBox(); // 自动步长
        _tableWidget->setCellWidget(_rowCount, 1, _checkBox_isAutoStepSize);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("自定义步长")));
        auto _doubleSpinBox_customStepSize = new BaseWidget::DoubleSpinBox(); // 自定义步长
        _tableWidget->setCellWidget(_rowCount, 1, _doubleSpinBox_customStepSize);
        _doubleSpinBox_customStepSize->setDecimals(15);
        _doubleSpinBox_customStepSize->setMinimum(0.000000000000001);
        _doubleSpinBox_customStepSize->setMaximum(1000000000000000);

         /*
         * checkbox 控制禁用状态
         */
        connect(_checkBox_isAutoStepSize, &QCheckBox::toggled, this,
                [=](bool checked)
                {
                    _doubleSpinBox_customStepSize->setEnabled(!checked);
                });

        //_tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("自动最小刻度")));
        // auto _checkBox_isAutoScale = new QCheckBox(); //自动最小刻度
        //_tableWidget->setCellWidget(_rowCount, 1, _checkBox_isAutoScale);

        //_tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("自定义最小刻度数")));
        // auto _doubleSpinBox_mainScaleValue = new BaseWidget::DoubleSpinBox(); //自定义最小刻度数
        //_tableWidget->setCellWidget(_rowCount, 1, _doubleSpinBox_mainScaleValue);

        // 设置第一列不可编辑
        for (int _row = 0; _row < _tableWidget->rowCount(); ++_row)
        {
            QTableWidgetItem* item = _tableWidget->item(_row, 0);
            item->setFlags(item->flags() & ~Qt::ItemIsEditable);
        }

        return _tableWidget;
    }

    QTableWidget* DialogHeatGraph2DSettings::initData_yAxisDisplay()
    {

        auto _tableWidget = initData_xAxisDisplay();

        return _tableWidget;
    }

    QTableWidget* DialogHeatGraph2DSettings::initData_yAxisRange()
    {

        auto _tableWidget = initData_xAxisRange();

        return _tableWidget;
    }

    QTableWidget* DialogHeatGraph2DSettings::initData_grid()
    {
        auto _tableWidget = new QTableWidget();
        _tableWidget->setColumnCount(2);
        _tableWidget->setRowCount(8);
        _tableWidget->setHorizontalHeaderLabels(QStringLiteral("名称,值").split(","));
        _tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

        auto _lineWidthList = GlobalHelperInstance->getLineWidthList();

        int _rowCount = -1;
        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("主网格线显示")));
        auto _checkBox_isMainGridLineDisplay = new QCheckBox(); // 主网格线显示
        _tableWidget->setCellWidget(_rowCount, 1, _checkBox_isMainGridLineDisplay);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("主网格线颜色")));
        auto _comboBox_mainGridLineColor = new BaseWidget::EColorComboBox; // 主网格线颜色
        _comboBox_mainGridLineColor->appendPredefinedColors();
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_mainGridLineColor);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("主网格线样式")));
        auto _comboBox_mainGridLineStyle = new LineStyleComboBox; // 主网格线样式
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_mainGridLineStyle);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("主网格线粗细")));
        auto _comboBox_mainGridLineThickness = new QComboBox(); // 主网格线粗细
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_mainGridLineThickness);
        for (int i = 0; i < _lineWidthList.size(); ++i)
        {
            _comboBox_mainGridLineThickness->addItem(_lineWidthList.at(i));
        }

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("次网格线显示")));
        auto _doubleSpinBox_isSecondaryGridLineDisplay = new QCheckBox(); // 次网格线显示
        _tableWidget->setCellWidget(_rowCount, 1, _doubleSpinBox_isSecondaryGridLineDisplay);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("次网格线颜色")));
        auto _comboBox_secondaryGridLineColor = new BaseWidget::EColorComboBox; // 次网格线颜色
        _comboBox_secondaryGridLineColor->appendPredefinedColors();
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_secondaryGridLineColor);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("次网格线样式")));
        auto _comboBox_secondaryGridLineStyle = new LineStyleComboBox; // 次网格线样式
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_secondaryGridLineStyle);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("次网格线粗细")));
        auto _comboBox_secondaryGridLineThickness = new QComboBox(); // 次网格线粗细
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_secondaryGridLineThickness);
        for (int i = 0; i < _lineWidthList.size(); ++i)
        {
            _comboBox_secondaryGridLineThickness->addItem(_lineWidthList.at(i));
        }

        // 设置第一列不可编辑
        for (int _row = 0; _row < _tableWidget->rowCount(); ++_row)
        {
            QTableWidgetItem* item = _tableWidget->item(_row, 0);
            item->setFlags(item->flags() & ~Qt::ItemIsEditable);
        }

        return _tableWidget;
    }

    QTableWidget* DialogHeatGraph2DSettings::initData_title()
    {
        auto _tableWidget = new QTableWidget();
        _tableWidget->setColumnCount(2);
        _tableWidget->setRowCount(3);
        _tableWidget->setHorizontalHeaderLabels(QStringLiteral("名称,值").split(","));
        _tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

        auto _fontSizeList = GlobalHelperInstance->getFontSizeList();

        int _rowCount = -1;
        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("标题名")));
        auto _lineEdit_title = new QLineEdit; // 标题名
        _tableWidget->setCellWidget(_rowCount, 1, _lineEdit_title);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("标题字体颜色")));
        auto _comboBox_titleFontColor = new BaseWidget::EColorComboBox; // 标题字体颜色
        _comboBox_titleFontColor->appendPredefinedColors();
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_titleFontColor);

        _tableWidget->setItem(++_rowCount, 0, new QTableWidgetItem(QStringLiteral("标题字体大小")));
        auto _comboBox_titleFontSize = new QComboBox; // 标题字体大小
        _tableWidget->setCellWidget(_rowCount, 1, _comboBox_titleFontSize);
        for (int i = 0; i < _fontSizeList.size(); ++i)
        {
            _comboBox_titleFontSize->addItem(_fontSizeList.at(i));
        }

        // 设置第一列不可编辑
        for (int _row = 0; _row < _tableWidget->rowCount(); ++_row)
        {
            QTableWidgetItem* item = _tableWidget->item(_row, 0);
            item->setFlags(item->flags() & ~Qt::ItemIsEditable);
        }

        return _tableWidget;
    }

    void DialogHeatGraph2DSettings::saveUIData_colorBar()
    {
        auto _tableWidget = m_tableWidget_colorBar;
        auto _colorBar = m_dataHeatGraph2DSettings->getColorBar();

        int _rowCount = -1;
        auto _checkBox_isAutoRange = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                   // 自动范围
        auto _doubleSpinBox_maxValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 最大值
        auto _doubleSpinBox_minValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 最小值
        auto _comboBox_fontColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);    // 字体颜色
        auto _comboBox_fontSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                      // 字体大小

        _colorBar->m_isAutoRange = _checkBox_isAutoRange->isChecked();
        _colorBar->m_maxValue = _doubleSpinBox_maxValue->value();
        _colorBar->m_minValue = _doubleSpinBox_minValue->value();
        _colorBar->m_fontColor = _comboBox_fontColor->currentColor();
        _colorBar->m_fontSize = _comboBox_fontSize->currentText().toInt();
    }

    void DialogHeatGraph2DSettings::saveUIData_xAxisDisplay()
    {
        auto _tableWidget = m_tableWidget_xAxisDisplay;
        auto _xAxisDisplay = m_dataHeatGraph2DSettings->getXAxisDisplay();

        int _rowCount = -1;
        auto _checkBox_isAutoName = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                          // 自动命名
        auto _lineEdit_title = (QLineEdit*)_tableWidget->cellWidget(++_rowCount, 1);                               // 标题名
        auto _comboBox_titleFontColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);     // 标题字体颜色
        auto _comboBox_titleFontSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 标题字体大小
        auto _comboBox_axisColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);          // 轴线颜色
        auto _comboBox_axisThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 轴线粗细
        auto _SpinBox_valuePrecision = (QSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);                        // 数值精度
        auto _comboBox_axisDigitColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);     // 轴数字颜色
        auto _comboBox_axisDigitSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 轴数字大小

        _xAxisDisplay->m_isAutoName = _checkBox_isAutoName->isChecked();
        _xAxisDisplay->m_titleText = _lineEdit_title->text();
        _xAxisDisplay->m_titleFontColor = _comboBox_titleFontColor->currentColor();
        _xAxisDisplay->m_titleFontSize = _comboBox_titleFontSize->currentText().toInt();
        _xAxisDisplay->m_axisColor = _comboBox_axisColor->currentColor();
        _xAxisDisplay->m_axisThickness = _comboBox_axisThickness->currentText().toInt();
        _xAxisDisplay->m_valuePrecision = _SpinBox_valuePrecision->value();
        _xAxisDisplay->m_axisDigitColor = _comboBox_axisDigitColor->currentColor();
        _xAxisDisplay->m_axisDigitSize = _comboBox_axisDigitSize->currentText().toInt();
    }

    void DialogHeatGraph2DSettings::saveUIData_xAxisRange()
    {
        auto _tableWidget = m_tableWidget_xAxisRange;
        auto _xAxisRange = m_dataHeatGraph2DSettings->getXAxisRange();

        int _rowCount = -1;
        auto _checkBox_isAutoRange = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                         // 自动范围
        auto _doubleSpinBox_maxValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);       // 最大值
        auto _doubleSpinBox_minValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);       // 最小值
        auto _checkBox_isAutoStepSize = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                      // 自动步长
        auto _doubleSpinBox_customStepSize = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 自定义步长
        auto _checkBox_isAutoScale = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                         // 自动最小刻度
        auto _doubleSpinBox_mainScaleValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 自定义最小刻度数

        auto maxValue = qMax(_doubleSpinBox_maxValue->value(), _doubleSpinBox_minValue->value());
        auto minValue = qMin(_doubleSpinBox_maxValue->value(), _doubleSpinBox_minValue->value());
        _doubleSpinBox_maxValue->setValue(maxValue);
        _doubleSpinBox_minValue->setValue(minValue);

        _xAxisRange->m_isAutoRange = _checkBox_isAutoRange->isChecked();
        _xAxisRange->m_maxValue = _doubleSpinBox_maxValue->value();
        _xAxisRange->m_minValue = _doubleSpinBox_minValue->value();
        _xAxisRange->m_isAutoStepSize = _checkBox_isAutoStepSize->isChecked();
        _xAxisRange->m_customStepSize = _doubleSpinBox_customStepSize->value();
        //_xAxisRange->m_isAutoScale = _checkBox_isAutoScale->isChecked();
        //_xAxisRange->m_mainScaleValue = _doubleSpinBox_mainScaleValue->value();
    }

    void DialogHeatGraph2DSettings::saveUIData_yAxisDisplay()
    {
        auto _tableWidget = m_tableWidget_yAxisDisplay;
        auto _yAxisDisplay = m_dataHeatGraph2DSettings->getYAxisDisplay();

        int _rowCount = -1;
        auto _checkBox_isAutoName = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                          // 自动命名
        auto _lineEdit_title = (QLineEdit*)_tableWidget->cellWidget(++_rowCount, 1);                               // 标题名
        auto _comboBox_titleFontColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);     // 标题字体颜色
        auto _comboBox_titleFontSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 标题字体大小
        auto _comboBox_axisColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);          // 轴线颜色
        auto _comboBox_axisThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 轴线粗细
        auto _SpinBox_valuePrecision = (QSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);                        // 数值精度
        auto _comboBox_axisDigitColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);     // 轴数字颜色
        auto _comboBox_axisDigitSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 轴数字大小

        _yAxisDisplay->m_isAutoName = _checkBox_isAutoName->isChecked();
        _yAxisDisplay->m_titleText = _lineEdit_title->text();
        _yAxisDisplay->m_titleFontColor = _comboBox_titleFontColor->currentColor();
        _yAxisDisplay->m_titleFontSize = _comboBox_titleFontSize->currentText().toInt();
        _yAxisDisplay->m_axisColor = _comboBox_axisColor->currentColor();
        _yAxisDisplay->m_axisThickness = _comboBox_axisThickness->currentText().toInt();
        _yAxisDisplay->m_valuePrecision = _SpinBox_valuePrecision->value();
        _yAxisDisplay->m_axisDigitColor = _comboBox_axisDigitColor->currentColor();
        _yAxisDisplay->m_axisDigitSize = _comboBox_axisDigitSize->currentText().toInt();
    }

    void DialogHeatGraph2DSettings::saveUIData_yAxisRange()
    {
        auto _tableWidget = m_tableWidget_yAxisRange;
        auto _yAxisRange = m_dataHeatGraph2DSettings->getYAxisRange();

        int _rowCount = -1;
        auto _checkBox_isAutoRange = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                         // 自动范围
        auto _doubleSpinBox_maxValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);       // 最大值
        auto _doubleSpinBox_minValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);       // 最小值
        auto _checkBox_isAutoStepSize = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                      // 自动步长
        auto _doubleSpinBox_customStepSize = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 自定义步长

        _yAxisRange->m_isAutoRange = _checkBox_isAutoRange->isChecked();
        _yAxisRange->m_maxValue = _doubleSpinBox_maxValue->value();
        _yAxisRange->m_minValue = _doubleSpinBox_minValue->value();

        auto maxValue = qMax(_yAxisRange->m_maxValue, _yAxisRange->m_minValue);
        auto minValue = qMin(_yAxisRange->m_maxValue, _yAxisRange->m_minValue);
        _doubleSpinBox_maxValue->setValue(maxValue);
        _doubleSpinBox_minValue->setValue(minValue);

        _yAxisRange->m_isAutoStepSize = _checkBox_isAutoStepSize->isChecked();
        _yAxisRange->m_customStepSize = _doubleSpinBox_customStepSize->value();
    }

    void DialogHeatGraph2DSettings::saveUIData_grid()
    {
        auto _tableWidget = m_tableWidget_grid;
        auto _grid = m_dataHeatGraph2DSettings->getGrid();

        int _rowCount = -1;
        auto _checkBox_isMainGridLineDisplay = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                   // 是否主网格线显示
        auto _comboBox_mainGridLineColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);      // 主网格线颜色
        auto _comboBox_mainGridLineStyle = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 主网格线样式
        auto _comboBox_mainGridLineThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                   // 主网格线粗细
        auto _doubleSpinBox_isSecondaryGridLineDisplay = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);         // 是否次网格线显示
        auto _comboBox_secondaryGridLineColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1); // 次网格线颜色
        auto _comboBox_secondaryGridLineStyle = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                  // 次网格线样式
        auto _comboBox_secondaryGridLineThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);              // 次网格线粗细

        _grid->m_isMainGridLineDisplay = _checkBox_isMainGridLineDisplay->isChecked();
        _grid->m_mainGridLineColor = _comboBox_mainGridLineColor->currentColor();
        _grid->m_mainGridLineStyle = _comboBox_mainGridLineStyle->currentIndex();
        _grid->m_mainGridLineThickness = _comboBox_mainGridLineThickness->currentText().toDouble();
        _grid->m_isSecondaryGridLineDisplay = _doubleSpinBox_isSecondaryGridLineDisplay->isChecked();
        _grid->m_secondaryGridLineColor = _comboBox_secondaryGridLineColor->currentColor();
        _grid->m_secondaryGridLineStyle = _comboBox_secondaryGridLineStyle->currentIndex();
        _grid->m_secondaryGridLineThickness = _comboBox_secondaryGridLineThickness->currentText().toDouble();
    }

    void DialogHeatGraph2DSettings::saveUIData_title()
    {
        auto _tableWidget = m_tableWidget_title;
        auto _title = m_dataHeatGraph2DSettings->getTitle();

        int _rowCount = -1;
        auto _lineEdit_title = (QLineEdit*)_tableWidget->cellWidget(++_rowCount, 1);                           // 标题名
        auto _comboBox_titleFontColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1); // 标题字体颜色
        auto _comboBox_titleFontSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                   // 标题字体大小

        _title->m_titleName = _lineEdit_title->text();
        _title->m_titleFontColor = _comboBox_titleFontColor->currentColor();
        _title->m_titleFontSize = _comboBox_titleFontSize->currentText().toInt();
        emit signal_titleRename();
    }

    void DialogHeatGraph2DSettings::updateUIData_colorBar()
    {
        auto _tableWidget = m_tableWidget_colorBar;
        auto _colorBar = m_dataHeatGraph2DSettings->getColorBar();

        int _rowCount = -1;
        auto _checkBox_isAutoRange = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                   // 自动范围
        auto _doubleSpinBox_maxValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 最大值
        auto _doubleSpinBox_minValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 最小值
        auto _comboBox_fontColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);    // 字体颜色
        auto _comboBox_fontSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                      // 字体大小

        _checkBox_isAutoRange->setChecked(_colorBar->m_isAutoRange);
        _doubleSpinBox_maxValue->setValue(_colorBar->m_maxValue);
        _doubleSpinBox_minValue->setValue(_colorBar->m_minValue);
        _comboBox_fontColor->setCurrentColor(_colorBar->m_fontColor);
        _comboBox_fontSize->setCurrentText(QString::number(_colorBar->m_fontSize));
    }

    void DialogHeatGraph2DSettings::updateUIData_xAxisDisplay()
    {
        auto _tableWidget = m_tableWidget_xAxisDisplay;
        auto _xAxisDisplay = m_dataHeatGraph2DSettings->getXAxisDisplay();

        int _rowCount = -1;
        auto _checkBox_isAutoName = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                          // 自动命名
        auto _lineEdit_title = (QLineEdit*)_tableWidget->cellWidget(++_rowCount, 1);                               // 标题名
        auto _comboBox_titleFontColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);     // 标题字体颜色
        auto _comboBox_titleFontSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 标题字体大小
        auto _comboBox_axisColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);          // 轴线颜色
        auto _comboBox_axisThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 轴线粗细
        auto _SpinBox_valuePrecision = (QSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);                        // 数值精度
        auto _comboBox_axisDigitColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);     // 轴数字颜色
        auto _comboBox_axisDigitSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 轴数字大小

        _checkBox_isAutoName->setChecked(_xAxisDisplay->m_isAutoName);
        _lineEdit_title->setText(_xAxisDisplay->m_titleText);
        _comboBox_titleFontColor->setCurrentColor(_xAxisDisplay->m_titleFontColor);
        _comboBox_titleFontSize->setCurrentText(QString::number(_xAxisDisplay->m_titleFontSize));
        _comboBox_axisColor->setCurrentColor(_xAxisDisplay->m_axisColor);
        _comboBox_axisThickness->setCurrentText(QString::number(_xAxisDisplay->m_axisThickness));
        _SpinBox_valuePrecision->setValue(_xAxisDisplay->m_valuePrecision);
        _comboBox_axisDigitColor->setCurrentColor(_xAxisDisplay->m_axisDigitColor);
        _comboBox_axisDigitSize->setCurrentText(QString::number(_xAxisDisplay->m_axisDigitSize));
    }

    void DialogHeatGraph2DSettings::updateUIData_xAxisRange()
    {
        auto _tableWidget = m_tableWidget_xAxisRange;
        auto _xAxisRange = m_dataHeatGraph2DSettings->getXAxisRange();

        int _rowCount = -1;
        auto _checkBox_isAutoRange = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                         // 自动范围
        auto _doubleSpinBox_maxValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);       // 最大值
        auto _doubleSpinBox_minValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);       // 最小值
        auto _checkBox_isAutoStepSize = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                      // 自动步长
        auto _doubleSpinBox_customStepSize = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 自定义步长
        auto _checkBox_isAutoScale = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                         // 自动最小刻度
        auto _doubleSpinBox_mainScaleValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 自定义最小刻度数

        _checkBox_isAutoRange->setChecked(_xAxisRange->m_isAutoRange);
        _doubleSpinBox_maxValue->setValue(_xAxisRange->m_maxValue);
        _doubleSpinBox_minValue->setValue(_xAxisRange->m_minValue);
        _checkBox_isAutoStepSize->setChecked(_xAxisRange->m_isAutoStepSize);
        _doubleSpinBox_customStepSize->setValue(_xAxisRange->m_customStepSize);
        //_checkBox_isAutoScale->setChecked(_xAxisRange->m_isAutoScale);
        //_doubleSpinBox_mainScaleValue->setValue(_xAxisRange->m_mainScaleValue);
    }

    void DialogHeatGraph2DSettings::updateUIData_yAxisDisplay()
    {
        auto _tableWidget = m_tableWidget_yAxisDisplay;
        auto _yAxisDisplay = m_dataHeatGraph2DSettings->getYAxisDisplay();

        int _rowCount = -1;
        auto _checkBox_isAutoName = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                          // 自动命名
        auto _lineEdit_title = (QLineEdit*)_tableWidget->cellWidget(++_rowCount, 1);                               // 标题名
        auto _comboBox_titleFontColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);     // 标题字体颜色
        auto _comboBox_titleFontSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 标题字体大小
        auto _comboBox_axisColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);          // 轴线颜色
        auto _comboBox_axisThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 轴线粗细
        auto _SpinBox_valuePrecision = (QSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 数值精度
        auto _comboBox_axisDigitColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);     // 轴数字颜色
        auto _comboBox_axisDigitSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 轴数字大小

        _checkBox_isAutoName->setChecked(_yAxisDisplay->m_isAutoName);
        _lineEdit_title->setText(_yAxisDisplay->m_titleText);
        _comboBox_titleFontColor->setCurrentColor(_yAxisDisplay->m_titleFontColor);
        _comboBox_titleFontSize->setCurrentText(QString::number(_yAxisDisplay->m_titleFontSize));
        _comboBox_axisColor->setCurrentColor(_yAxisDisplay->m_axisColor);
        _comboBox_axisThickness->setCurrentText(QString::number(_yAxisDisplay->m_axisThickness));
        _SpinBox_valuePrecision->setValue(_yAxisDisplay->m_valuePrecision);
        _comboBox_axisDigitColor->setCurrentColor(_yAxisDisplay->m_axisDigitColor);
        _comboBox_axisDigitSize->setCurrentText(QString::number(_yAxisDisplay->m_axisDigitSize));
    }

    void DialogHeatGraph2DSettings::updateUIData_yAxisRange()
    {
        auto _tableWidget = m_tableWidget_yAxisRange;
        auto _yAxisRange = m_dataHeatGraph2DSettings->getYAxisRange();

        int _rowCount = -1;
        auto _checkBox_isAutoRange = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                         // 自动范围
        auto _doubleSpinBox_maxValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);       // 最大值
        auto _doubleSpinBox_minValue = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1);       // 最小值
        auto _checkBox_isAutoStepSize = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                      // 自动步长
        auto _doubleSpinBox_customStepSize = (BaseWidget::DoubleSpinBox*)_tableWidget->cellWidget(++_rowCount, 1); // 自定义步长
        _checkBox_isAutoRange->setChecked(_yAxisRange->m_isAutoRange);
        _checkBox_isAutoStepSize->setChecked(_yAxisRange->m_isAutoStepSize);
        _doubleSpinBox_customStepSize->setValue(_yAxisRange->m_customStepSize);
        _doubleSpinBox_maxValue->setValue(_yAxisRange->m_maxValue);
        _doubleSpinBox_minValue->setValue(_yAxisRange->m_minValue);
    }

    void DialogHeatGraph2DSettings::updateUIData_grid()
    {
        auto _tableWidget = m_tableWidget_grid;
        auto _grid = m_dataHeatGraph2DSettings->getGrid();

        int _rowCount = -1;
        auto _checkBox_isMainGridLineDisplay = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);                   // 是否主网格线显示
        auto _comboBox_mainGridLineColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1);      // 主网格线颜色
        auto _comboBox_mainGridLineStyle = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                       // 主网格线样式
        auto _comboBox_mainGridLineThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                   // 主网格线粗细
        auto _doubleSpinBox_isSecondaryGridLineDisplay = (QCheckBox*)_tableWidget->cellWidget(++_rowCount, 1);         // 是否次网格线显示
        auto _comboBox_secondaryGridLineColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1); // 次网格线颜色
        auto _comboBox_secondaryGridLineStyle = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                  // 次网格线样式
        auto _comboBox_secondaryGridLineThickness = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);              // 次网格线粗细

        _checkBox_isMainGridLineDisplay->setChecked(_grid->m_isMainGridLineDisplay);
        _comboBox_mainGridLineColor->setCurrentColor(_grid->m_mainGridLineColor);
        _comboBox_mainGridLineStyle->setCurrentIndex(_grid->m_mainGridLineStyle);
        _comboBox_mainGridLineThickness->setCurrentText(QString::number(_grid->m_mainGridLineThickness));
        _doubleSpinBox_isSecondaryGridLineDisplay->setChecked(_grid->m_isSecondaryGridLineDisplay);
        _comboBox_secondaryGridLineColor->setCurrentColor(_grid->m_secondaryGridLineColor);
        _comboBox_secondaryGridLineStyle->setCurrentIndex(_grid->m_secondaryGridLineStyle);
        _comboBox_secondaryGridLineThickness->setCurrentText(QString::number(_grid->m_secondaryGridLineThickness));
    }

    void DialogHeatGraph2DSettings::updateUIData_title()
    {
        QSignalBlocker blocker(m_tableWidget_title);
        auto _tableWidget = m_tableWidget_title;
        auto _title = m_dataHeatGraph2DSettings->getTitle();

        int _rowCount = -1;
        auto _lineEdit_title = (QLineEdit*)_tableWidget->cellWidget(++_rowCount, 1);                           // 标题名
        auto _comboBox_titleFontColor = (BaseWidget::EColorComboBox*)_tableWidget->cellWidget(++_rowCount, 1); // 标题字体颜色
        auto _comboBox_titleFontSize = (QComboBox*)_tableWidget->cellWidget(++_rowCount, 1);                   // 标题字体大小

        _lineEdit_title->setText(_title->m_titleName);
        _comboBox_titleFontColor->setCurrentColor(_title->m_titleFontColor);
        _comboBox_titleFontSize->setCurrentText(QString::number(_title->m_titleFontSize));
    }

} // namespace pst
